// 导入本地存储模块组件
import { getInfo, setInfo, getAdress, setAddress } from '@/utils/storage'

export default {
  namespaced: true,
  state () {
    return {
      userInfo: getInfo(),
      address: getAdress() || {}

    }
  },
  mutations: {
    setUserInfo (state, obj) {
      state.userInfo = obj
      //   在本地存一份
      setInfo(obj)
    },
    setAddress (state, data) {
      state.address = data
      setAddress(data)
    }
  },
  actions: {
    logout (context) {
      // 个人信息重置
      context.commit('setUserInfo', {})
      // 购物车信息重置 跨模块调用
      context.dispatch('cart/resetCartList', [], { root: true })
    }
  },
  getters: {}

}
